package com.kaishengit.web;


import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.kaishengit.dao.EPDao;
import com.kaishengit.dao.PDao;
import com.kaishengit.entity.Employee;
import com.kaishengit.entity.Ep;
import com.kaishengit.entity.Project;

public class ProjectServlet extends HttpServlet {

	private static final long serialVersionUID = 1L;
	public void destroy() {
	}
	
	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		String projectid=request.getParameter("projectid");
		HttpSession session=request.getSession();
		PDao pdao=new PDao();
		Project project=pdao.findById(projectid);
		session.setAttribute("project",project);
		Employee emp=(Employee)session.getAttribute("emp");
		EPDao epdao=new EPDao();
		Ep ep=epdao.findByEmployeeidAndProjectid(emp.getId(),projectid);
		session.setAttribute("ep",ep);
		request.getRequestDispatcher("/WEB-INF/views/project.jsp").forward(request,response);
	}
	
	public void init() throws ServletException {
	}

}

